﻿namespace NuGetCop.MSBuild.Tasks.Configuration
{
    using System;
    using System.Xml;
    using NuGetCop.MSBuild.Tasks.Configuration.Readers;

    internal sealed class NuGetCopSettingsProvider : INuGetCopSettingsProvider
    {
        private readonly INuGetCopSettingsReader<Uri> settingsReader;

        public NuGetCopSettingsProvider()
        {
            var xmlSettings = new XmlReaderSettings();
            var settingsReaderFactory = new NuGetCopSettingsXmlReaderFactory(xmlSettings);

            settingsReader = settingsReaderFactory.CreateReader();
        }

        public NuGetCopSettings GetSettings(Uri targetUri)
        {
            var settings = settingsReader.ReadSettings(targetUri);
            return settings;
        }
    }
}
